<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="../../../common/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<sfa:mainTitle></sfa:mainTitle>
		<%@ include file="../../../common/meta.jsp"%>
<script type="text/javascript"
			src="${path}/script/lhgdialog/lhgdialog.min.js"></script>
			
<script type="text/javascript" src="${path }/script/TreePanel/common-min.js"></script>		
<script type="text/javascript" src="${path }/script/TreePanel/TreePanel.js"></script>		
<link rel="stylesheet" href="${path }/script/TreePanel/TreePanel.css" type="text/css"></link>
<link rel="stylesheet" type="text/css"
			href="${path}/css/step/an.css" >
			
		<style type="text/css">
* {
	margin: 0;
	padding: 0;
}

.tc_box {
	width: 400px;
	height: 200px;
	border: 2px solid red;
	position: absolute;
	z-index: 2000;
	background: #FFC;
	display: none;
}

.sp_box {
	width: 100%;
	position: absolute;
	z-index: 1000;
	background: #000;
	top: 0;
	left: 0;
	display: none;
}
.main .formdiv {
	width: 400px;
}
</style>
<script type="text/javascript">
$(function() {

	
	$("#clear").click(function() {
		$(".inputbox").val("");
		$(".areabox").val("");
	});

	$("#next").click(function() {
		//alert("dddddddddd");

		var url = "${path}/manage/role/index/validate";
		var roleName = $("#roleName").val();


		var param = {
			"roleName" : roleName,
		};
		$.post(url, param, function(data) {
			
			var json =eval(data);
			//alert(json);
			if (json.result ==true) {
				$("#step1").css("display", "none");
				$("#step2").css("display", "block");
				
				$("#firstStep").attr("class", "");
				$("#firstStep_line").attr("class","line_last");
				$("#secondStep").attr("class","now");
				$("#secondStep_line").attr("class","line_frist");
			} else {
				$(".checkInfo").html(json.roleName);
			}
		});

	});
	
	$("#provi").click(function() {

				$("#step2").css("display", "none");
				$("#step1").css("display", "block");
				

				$("#firstStep").attr("class", "now");
				$("#firstStep_line").attr("class","line_frist");
				$("#secondStep").attr("class","");
				$("#secondStep_line").attr("class","line");


	});

	$("#submit").click(
			function() {
				//alert("sssssssss");
				var url = "${path}/manage/role/index/newrole";
				var roleName = $("#roleName").val();
				var roleContent = $("#roleContent").val();
				var roleStatus = $("#roleStatus").val();
				var checkModes = tree.getChecked();
					
				var param = {
					"roleName" : roleName,
					"roleContent" : roleContent,
					"roleStatus" : roleStatus,
					"checkModes" : checkModes
				};
				
				$.post(url, param, function(data) {
					//alert(data);
					var json =  eval(data);

					if (json.result ==true) {
						$("#step3").css("display", "block");
						$("#step2").css("display", "none");
						
						$("#firstStep_line").attr("class","line");
						$("#secondStep").attr("class", "");
						$("#secondStep_line").attr("class","line_last");
						$("#thirdStep").attr("class","now");
						$("#thirdStep_line").attr("class","line_over");
					
					} else {
						$(".meetingTitle").html(json.meetingTitle);
						$(".meetingContent").html(json.meetingContent);
						$(".mCount").html(json.meetingCount);
						$(".startDate").html(json.startDate);
						$(".endDate").html(json.endDate);
					}
					$(".add").html(json.add);
				});

			});
				
				

	
});
</script>
<link rel="stylesheet" type="text/css"
			href="${path}/css/addnews/step1.css" id="step">
	</head>

	<body id="master">

		<sfa:mainHeader></sfa:mainHeader>

			<!--右边-->
            <div class="webpart3 contentarea">
                <div class="webpart-head">
                    <div class="webpart-head-item">
                        新建角色
                    </div>
                </div>
                <div class="webpart-main">
                    <div class="webpart-main-item" style="padding: 12px;">
                    	
                    	<div class="at_loc">
		<span class="now" style="width:208px;" id="firstStep">1.填写角色名称</span>
		<span class="line_frist" id="firstStep_line"></span>
		<span style="width:208px;" id="secondStep">2.选择模块</span>
		<span class="line" id="secondStep_line"></span>
		
		<span style="width:208px;" id="thirdStep">3.确认结果</span>
		<span class="line_end" id="thirdStep_line"></span>
		</div>
           <!--  <input type='button' value='删除当前节点' onclick='deleteNode()'>
<input type='button' value='查看当前节点' onclick='seeFocusNode()'>
<input type='button' value='查看选中节点数' onclick='fChecked()'>
<input type='button' value='添加节点' onclick='addNode()'>
<input type='button' value='展开全部节点' onclick='expandAll()'>
<input type='button' value='折叠全部节点' onclick='collapseAll()'>      -->    	
                    	
                        <div class="d_formitem">
                        
							<div id="step1">				
                            <table cellspacing="0" cellpadding="0"  >
                                <tr>
                                    <th style="width: 60px;">
                                        角色名称:
                                    </th>
                                    <td>
                                        <input type="text" class="input-txt" id="roleName"
											name="roleName" style="width: 400px;" />
									<font color="red">*</font><font color="red" class="checkInfo"></font>
                                    </td>
                                </tr>
                                
                                <tr>
                                    <th style="width: 60px;">
                                        角色描述:
                                    </th>
                                    <td>
                                        <input type="text" class="input-txt" id="roleContent"
											name="roleContent" style="width: 400px;" />
                                    </td>
                                </tr>
                                
                                <tr>
                                    <th style="width: 60px;">
                                        角色状态:
                                    </th>
                                    <td>
                                        <select type="text" name="roleStatus" id="roleStatus" class="input-txt">
								 					 <option value="1">启用</option>
								 					 <option value="0">禁用</option>
								 		</select>
                                    </td>
                                </tr>
                                
                                <tr>
                                    <td align="center">
										<input name="next" type="button" id="next" tabindex="5"
											class="linkbtn2" value="下一步">
									</td>
                                </tr>
                                
                            </table>
                             <ckfinder:setupCKEditor editor="meetingContent"
							basePath="/sfa/ckfinder/" />
						<ckeditor:replace replace="meetingContent" basePath="/ckeditor/"></ckeditor:replace>
						</div>
						
						
						
						<div id="step2" style="display: none;">				
                            <table cellspacing="0" cellpadding="0" class="formitem">
                                <tr>
                                    <th style="width: 75px;">
                                       选择模块:
                                    </th>
                                    <td>
                                     <div id="test"></div>
                                     </td>
                                </tr>
                               
                                <tr>
								<th colspan="2">
									<input name="submit" type="button" id="submit" tabindex="5"
										class="linkbtn2" value="提交">&nbsp;<input name="provi" type="button" id="provi" tabindex="5"
											class="linkbtn2" value="上一步">
								</th>
							</tr>
                                
                            </table>
                              
						</div>
						<div id="step3" style="display: none;">
					<div>
						<font color="red" class="add"> </font><a
							href="${path}/manage/role/index/getmodule">继续添加</a>
							|<a href="${path}/manage/role/index/getroles">跳到管理页面</a>
					</div>
					
					
						</div>
						
						
                        </div>
                    </div>
                </div>
                <div class="webpart-foot">
                    <div class="webpart-foot-item">
                    </div>
                </div>
            </div>
		<sfa:mainFooter></sfa:mainFooter>
	
	</body>
	

	<script type=text/javascript>

	var l0 = new Date().getTime();
	
	$.ajax({
		url:'${path}/manage/role/index/ajaxgetmodule',
		dataType:'json',
		success:function(result){
			tree = new TreePanel({
				'root' : result
			});

			tree.render();
		}
	});
	
	
	
	//alert( (new Date().getTime()-l0));

	function deleteNode(){
		var node = tree.focusNode;
		if(node){
			var parentNode = node.parentNode;
			if(parentNode){
				parentNode.removeChild(node);
			}
		}
	}
	
	function seeFocusNode(){
		var node = tree.focusNode;
		if(node!=null){
			alert('你选中的是'+ node.attributes.text );
		}else{
			alert('没有选中节点')
		}
	}
	
	function addNode(){
		var node = tree.focusNode;
		if(node!=null){
			var text = window.prompt('输入节点名称!','')
			if(text){
				var newNode = new TreeNode({text:text});
				node.appendChild(newNode);
			}
		}else{
			alert('没有选中节点')
		}
	}
	
	function expandAll(){
		tree.expandAll();
	}
	function collapseAll(){
		tree.collapseAll();
	}
	
	function fChecked(){
		tree.reChecked('LEM0000000000027');
		alert( tree.getChecked() );
	}
</script>
</html>


